package com.stefanini.pe.bbva.iivs.in.utils;




import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;



public class UtilFechas {
	private final static String FORMAT = "dd/MM/yyyy";
	private final static String FORMAT2 = "dd/MM/yyyy HH:mm:ss"; 
	//private final static String FORMAT_SALIDA = "MM/dd/yyyy";
	
	
	
	public static String fechaActual(){
	 	SimpleDateFormat formato = new SimpleDateFormat(FORMAT);
	 	Calendar c1 = Calendar.getInstance(); 
	 	return formato.format(c1.getTime());
	 }
	public static String fechaCaducidad(){
	 	SimpleDateFormat formato = new SimpleDateFormat(FORMAT);
	 	Calendar c1 = Calendar.getInstance();
	 
	 	return formato.format(c1.getTime());
	 }
	 
	public static Date fechaHoraActual(){
	 //	SimpleDateFormat formato = new SimpleDateFormat(FORMAT2);
	 	Calendar c1 = Calendar.getInstance(); 
	 	return c1.getTime();
	 	
	 }
	public static java.util.Date stringToUtilDate(String str, String pattern) {
        java.util.Date date = null;

        if(str != null && !str.trim().equals("")) {
            if (pattern == null) {
                //pattern = "yyyy-MM-dd";
            	pattern = "dd/MM/yyyy";
            }
            SimpleDateFormat formatter = new SimpleDateFormat(pattern);
            try {
				date = new java.util.Date(formatter.parse(str).getTime());
			} catch (ParseException e) {
				// Auto-generated catch block
				e.printStackTrace();
			}
        }
        return date;
    }
	 public static String utilDateToString(java.util.Date sqlDateFecha, String pattern) {
			String str = null;
			if (sqlDateFecha != null) {
				if (pattern == null) {
	                pattern = "dd/MM/yyyy";
	            }
	   			SimpleDateFormat formatter = new SimpleDateFormat(pattern);
	   			str = formatter.format(sqlDateFecha);
			}
			
			return str;
	}
}


